package com.atguigui.gulimall.cart.vo;

import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

public class CartVo {
    private List<CartItemVo> items;

    private BigDecimal totalPrice;
    /**
     * 商品数量
     */
    private Integer countNum;

    /**
     * 商品类型数量
     */
    private Integer countType;

    private BigDecimal reduce = new BigDecimal("0.00");;


    public List<CartItemVo> getItems() {
        return items;
    }

    public void setItems(List<CartItemVo> items) {
        this.items = items;
    }

    public BigDecimal getTotalPrice() {
        BigDecimal totalPrice = new BigDecimal("0");
        for (CartItemVo cartItemVo : items) {
            totalPrice = totalPrice.add(cartItemVo.getTotalPrice());
        }
        return totalPrice;
    }

    public void setTotalPrice(BigDecimal totalPrice) {
        this.totalPrice = totalPrice;
    }

    public Integer getCountNum() {
        int countNum = 0;
        for (CartItemVo cartItemVo : items) {
            countNum += cartItemVo.getAmount();
        }
        return countNum;
    }

    public void setCountNum(Integer countNum) {
        this.countNum = countNum;
    }

    public Integer getCountType() {
        int countType = 0;
        for (CartItemVo cartItemVo : items) {
            countType++;
        }
        return countType;
    }

    public void setCountType(Integer countType) {
        this.countType = countType;
    }

    public BigDecimal getReduce() {
        return reduce;
    }

    public void setReduce(BigDecimal reduce) {
        this.reduce = reduce;
    }
}
